/**
 * 
 */
package co.fitstart.coach.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.coach.CoachStudentRelation;
import co.fitstart.entity.course.CourseType;
import co.fitstart.entity.principal.Principal;
import co.fitstart.entity.user.Student;

/**
 * @author downpour
 *
 */
@Dynamic("hibernate")
public interface StudentDao {

    /**
     * load CoachStudentRelation
     * 
     * @param coach
     * @param courseType
     * @param student
     * @return
     */
    @Query("SELECT coachStudentRelation FROM CoachStudentRelation coachStudentRelation WHERE coachStudentRelation.coach = :coach AND coachStudentRelation.courseType = :courseType AND coachStudentRelation.student = :student")
    public CoachStudentRelation loadCoachStudentRelation(@Variable("coach")Principal coach, @Variable("courseType")CourseType courseType, @Variable("student")Student student);
    
    
    /**
     * list CoachStudentRelation
     * 
     * @param coach
     * @param courseType
     * @return
     */
    @Query("FROM CoachStudentRelation coachStudentRelation WHERE coachStudentRelation.coach = :coach AND coachStudentRelation.courseType = :courseType ORDER BY coachStudentRelation.lastUpdateTime DESC")
    public List<CoachStudentRelation> listCoachStudentRelation(@Variable("coach")Principal coach, @Variable("courseType")CourseType courseType);

}
